package cn.com.aiton.common.utils;

import cn.com.aiton.common.model.ServiceResult;
import cn.com.aiton.common.model.extend.AitonExtendReportStateRabbitMqDomain;
import cn.com.aiton.common.model.gbt209992007.GbtStagePatternDomain;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/6.
 */
public class JsonToReportStatusUtil {

    private static final Logger LOG =
            LoggerFactory.getLogger(JsonToReportStatusUtil.class);
    private static final ObjectMapper objectMapper = new ObjectMapper();
    public static ServiceResult str2ReportStatus(String json){
        ServiceResult message = new ServiceResult();
        try{
            AitonExtendReportStateRabbitMqDomain domain = objectMapper.readValue(json, AitonExtendReportStateRabbitMqDomain.class);
            message.setObject(domain);
            message.setSuccess(true);
            return message;
        }catch (Exception e){
            LOG.error(e.getMessage(),e);
            message.setSuccess(false);
            message.setMessage("数据转换出错");
            return message;
        }
    }

}
